﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.NeighborUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import flash.filters.*;
    import org.aswing.geom.*;
    import flash.text.*;
    import Display.aswingui.*;
    import L10n.*;

    public class FriendEnterRewardDialogView extends GenericDialogView {

        public static const FAKE_FRIEND_COMMODITY_AMOUNT:int = 200;

        protected var m_textShadow:DropShadowFilter;
        protected var m_amount:int;
        protected var m_amountField:JTextField;
        protected var m_friend:Player;
        protected var m_pic:Loader;
        protected var m_picHasLoaded:Boolean = false;
        private var m_friendFrameAP:AssetPane;
        private var m_coins:int;
        private var m_energy:int;
        private var m_xp:int;

        public function FriendEnterRewardDialogView(_arg1:Dictionary, _arg2:int=0, _arg3:int=0, _arg4:int=0, _arg5:String="", _arg6:String="", _arg7:int=0, _arg8:Function=null){
            this.m_coins = _arg2;
            this.m_energy = _arg3;
            this.m_xp = _arg4;
            super(_arg1, _arg5, _arg6, _arg7, _arg8);
        }
        public function get amount():int{
            return (this.m_amount);
        }
        public function get friend():Player{
            return (this.m_friend);
        }
        override protected function init():void{
            var _local1:String;
            this.m_textShadow = new DropShadowFilter(1, 90, 5602453, 1, 0, 0);
            m_acceptTextName = ZLoc.t("Dialogs", "Accept");
            m_cancelTextName = "";
            this.m_friend = m_assetDict["friend"];
            if (((this.m_friend) && (this.m_friend.snUser))){
                _local1 = this.m_friend.snUser.picture;
                if (_local1){
                    this.m_pic = LoadingManager.load(_local1, this.fillFriendFrame, LoadingManager.PRIORITY_LOW);
                    (this.m_pic as Loader).contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onLoadPicFail, false, 2);
                };
            };
            if (this.m_pic == null){
                this.m_pic = new EmbeddedArt.hud_no_profile_pic();
                this.m_pic.width = 48;
                this.m_pic.height = 48;
            };
            m_bgAsset = (new (m_assetDict["dialogBG"])() as DisplayObject);
            this.makeBackground();
            this.makeCenterPanel();
            ASwingHelper.prepare(this);
        }
        private function fillFriendFrame(_arg1:Event):void{
            var _local2:Sprite = new Sprite();
            var _local3:DisplayObject = this.m_pic;
            _local2.addChild(_local3);
            this.m_friendFrameAP.setAsset(_local2);
            this.m_picHasLoaded = true;
            _local3.width = (_local3.height = 48);
            ASwingHelper.prepare(this);
        }
        private function onLoadPicFail(_arg1:Event):void{
            if (!this.m_picHasLoaded){
                _arg1.stopPropagation();
                _arg1.stopImmediatePropagation();
                LoadingManager.cancelLoad(this.m_pic);
                this.m_picHasLoaded = true;
            };
        }
        override protected function makeBackground():void{
            var _local1:MarginBackground = new MarginBackground(m_bgAsset, new Insets(10, 0, 0, 5));
            this.setBackgroundDecorator(_local1);
            this.setPreferredSize(new IntDimension(m_bgAsset.width, m_bgAsset.height));
            this.setMinimumSize(new IntDimension(m_bgAsset.width, m_bgAsset.height));
            this.setMaximumSize(new IntDimension(m_bgAsset.width, m_bgAsset.height));
            this.setLayout(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.CENTER));
        }
        protected function makeIconPanel(_arg1:Class, _arg2:int, _arg3:String):JPanel{
            var _local4:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local5:DisplayObject = (new (_arg1)() as DisplayObject);
            var _local6:AssetPane = new AssetPane(_local5);
            var _local7:String = ZLoc.t("Dialogs", _arg3, {number:_arg2});
            var _local8:Number = 110;
            var _local9:AssetPane = ASwingHelper.makeMultilineText(_local7, _local8, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 15, EmbeddedArt.brownTextColor, null, true);
            _local9.setMinimumHeight((_local5.height + 8));
            var _local10:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            _local10.appendAll(ASwingHelper.verticalStrut(3), _local9);
            ASwingHelper.prepare(_local10);
            _local4.appendAll(ASwingHelper.horizontalStrut(22), _local6, ASwingHelper.horizontalStrut(4), _local10);
            ASwingHelper.prepare(_local4);
            return (_local4);
        }
        override protected function makeCenterPanel():void{
            var _local2:String;
            var _local1:JPanel = this.makeInfo();
            m_titlePanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            _local2 = ZLoc.t("Dialogs", "VRWhileVisiting", {name:ZLoc.tn(this.m_friend.snUser.firstName)});
            var _local3:Number = 140;
            var _local4:AssetPane = ASwingHelper.makeMultilineText(_local2, _local3, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 14, 3841479);
            LocaleHelper.localSetting.TextField_adjust((_local4.getAsset() as TextField), {
                embedFonts:false,
                font:EmbeddedArt.SYSTEM_FONT,
                size:13,
                leading:-4
            });
            LocaleHelper.localSetting.matchFontAdjust_SIM_HEI(_local4, {
                topMargin:2,
                textfield:(_local4.getAsset() as TextField),
                leading:0,
                size:15
            });
            m_titlePanel.append(ASwingHelper.verticalStrut(52));
            m_titlePanel.append(_local4);
            var _local5:int = this.m_coins;
            var _local6:int = this.m_energy;
            var _local7:int = this.m_xp;
            var _local8:JPanel = this.makeIconPanel(m_assetDict["coinIcon"], _local5, "VRNumCoins");
            var _local9:JPanel = this.makeIconPanel(m_assetDict["energyIcon"], _local6, "VRNumEnergy");
            var _local10:JPanel = this.makeIconPanel(m_assetDict["starXPIcon"], _local7, "VRNumXP");
            var _local11:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP, 0);
            _local11.appendAll(_local8, _local9, _local10);
            ASwingHelper.prepare(_local11);
            m_titlePanel.append(ASwingHelper.verticalStrut(8));
            m_titlePanel.append(_local11);
            m_titlePanel.append(ASwingHelper.verticalStrut(5));
            var _local12:CustomButton = new CustomButton(m_acceptTextName, null, "GreenButtonUI");
            _local12.addActionListener(onAccept, 0, true);
            m_titlePanel.append(_local12);
            ASwingHelper.prepare(m_titlePanel);
            _local1.append(m_titlePanel);
            var _local13:DisplayObject = (new (m_assetDict["closeBtnUp"])() as DisplayObject);
            var _local14:DisplayObject = (new (m_assetDict["closeBtnOver"])() as DisplayObject);
            var _local15:DisplayObject = (new (m_assetDict["closeBtnDown"])() as DisplayObject);
            var _local16:SimpleButton = new SimpleButton(_local13, _local14, _local15, _local13);
            var _local17:JButton = new JButton();
            _local17.wrapSimpleButton(_local16);
            _local17.addEventListener(MouseEvent.CLICK, onCancel, false, 0, true);
            var _local18:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            _local18.append(ASwingHelper.verticalStrut(20));
            _local18.appendAll(_local17);
            _local1.appendAll(ASwingHelper.horizontalStrut(-10), _local18);
            ASwingHelper.prepare(_local1);
            this.append(_local1);
            ASwingHelper.prepare(this);
        }
        private function makeInfo():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
            this.m_friendFrameAP = new AssetPane(new Sprite());
            LocaleHelper.localSetting.ASwingHelper_setPreferredHeight(this.m_friendFrameAP, 48);
            LocaleHelper.localSetting.ASwingHelper_setPreferredWidth(this.m_friendFrameAP, 48);
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            var _local3:JPanel = ASwingHelper.verticalStrut(32);
            _local2.append(_local3);
            _local2.append(this.m_friendFrameAP);
            _local2.append(ASwingHelper.horizontalStrut(54));
            ASwingHelper.prepare(_local2);
            _local1.appendAll(ASwingHelper.horizontalStrut(121), _local2);
            return (_local1);
        }

    }
}//package Display.NeighborUI 
